@extends('admin.main')

@section('body')
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>工人列表</h2>
    </div>
    <div class="cf">
        <div class="fl">
            @if(plat_identify() == 'account')
                <a class="btn" href="{{urlPlat('single','getWorkerAdd')}}">新 增</a>
            @endif
        </div>

        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <input type="text" name="keyword" class="search-input" value="{{request('keyword')}}"
                       placeholder="请输入姓名称或者工号">
                <a class="sch-btn" href="javascript:;" id="search" url="{{urlPlat('single','getWorker')}}"><i
                            class="btn-search"></i></a>
            </div>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
            <tr>
                @if(plat_identify() == 'account')<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>@endif
                <th class="">工号</th>
                <th class="">姓名</th>
                <th class="">手机号</th>
                <th class="">总派单量</th>
                <th class="">总送货量</th>
                <th class="">总回桶数</th>
                <th class="">老客户导入权限</th>
                <th class="">水票充值权限</th>
                <th class="">零送水取桶权限</th>
                    <th class="">代客下单权限</th>
                    <th class="">订单改派权限</th>
                <th class="">微信绑定</th>
                <th class="">状态</th>
                <th class="">创建时间</th>
                @if(plat_identify() == 'account')<th class="">操作</th>@endif
            </tr>
            </thead>
            <tbody>
            @if(count($rows['data']))
                @foreach($rows['data'] as $v)
                    <tr>
                        @if(plat_identify() == 'account')<td><input class="ids" type="checkbox" name="ids[]" value="{{$v['id']}}"/></td>@endif
                        <td>{{$v['code']}}</td>
                        <td>{{$v['name']}}</td>
                        <td>{{$v['mobile']}}</td>
                        <td>{{$v['total_order_num']}}</td>
                        <td>{{$v['total_bucket_num']}}</td>
                        <td>{{$v['total_back_bucket_num']}}</td>
                        <td style="color: @if($v['import_auth'] > 0) blue @else red @endif">{{$v['import_auth_text']}}</td>
                        <td style="color: @if($v['charge_auth'] > 0) blue @else red @endif">{{$v['charge_auth_text']}}</td>
                        <td style="color: @if($v['recover_auth'] > 0) blue @else red @endif">{{$v['recover_auth_text']}}</td>
                        <td style="color: @if($v['creat_order_auth'] > 0) blue @else red @endif">{{$v['creat_order_auth_text']}}</td>
                        <td style="color: @if($v['order_resend_auth'] > 0) blue @else red @endif">{{$v['order_resend_auth_text']}}</td>
                        <td style="color: @if($v['openid']) blue @else red @endif"> @if($v['openid']) 已绑定 @else 未绑定 @endif</td>
                        <td style="color: @if($v['status'] > 0) blue @else red @endif">{{$v['status_text']}}</td>
                        <td><span>{{$v['created_at']}}</span></td>
                        @if(plat_identify() == 'account')
                            <td>
                                <a title="编辑"
                                   href="{{urlPlat('single','getWorkerEdit',['id'=>$v['id']])}}">编辑</a>
                                @if($v['status'] == 1)
                                    <a href="{{urlPlat('single','anyChangeWorkerStatus',['status'=>0,'ids'=>$v['id']])}}"
                                       class="ajax-get" style="color:red">禁用</a>
                                @else
                                    <a href="{{urlPlat('single','anyChangeWorkerStatus',['status'=>1,'ids'=>$v['id']])}}"
                                       class="ajax-get" style="color:blue">启用</a>
                                @endif
                                @if($v['openid'])
                                    <a href="{{urlPlat('single','getWorkerRemoveBindWx',['id'=>$v['id']])}}"
                                       class="ajax-get" style="color:blue">解除绑定</a>
                                @endif
                            </td>
                        @endif
                    </tr>
                @endforeach
            @else
                <td colspan="12" class="text-center"> aOh! 暂时还没有内容!</td>
            @endif
            </tbody>
        </table>
    </div>
    <div class="page">
        @if($rows['last_page']>1)
            <div>
                @if($rows['prev_page_url'])
                    <a class="prev" href="{{$rows['prev_page_url']}}">&lt;&lt;</a>
                @endif
                @if(count($rows['pageNoList']))
                    @foreach($rows['pageNoList'] as $v)
                        @if($rows['current_page'] == $v)
                            <span class="current">{{$v}}</span>
                        @else
                            @if(request('shop_id'))
                                <a class="num"
                                   href="{{urlPlat('single','getWorker',['page'=>$v])}}">{{$v}}</a>
                            @else
                                <a class="num" href="{{urlPlat('single','getWorker',['page'=>$v])}}">{{$v}}</a>
                            @endif
                        @endif
                    @endforeach
                @endif
                @if($rows['next_page_url'])
                    <a class="next" href="{{$rows['next_page_url']}}">&gt;&gt;</a>
                @endif
                <span class="rows">共 {{$rows['total']}} 条记录</span>
            </div>
        @endif
    </div>
@endsection

@section('script')

    <script type="text/javascript">
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var shop_id = $("#sch-sort-txt").attr("data");
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (shop_id != '') {
                query = 'shop_id=' + shop_id + "&" + query;
            }
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
    </script>
@endsection
